using System;
using System.IO;
using System.Windows.Controls;
using System.Windows.Input;

namespace Seems.SL.VM
{
	public class ShellVM 
	{
		public ICommand SaveCommand { get; private set; }
		public ICommand LoadCommand { get; private set; }

		public DesignerVM Designer { get; private set; }

	    private IShellView shellView;
	    public IShellView ShellView
	    {
	        get { return shellView; }
	        set
	        {
	            shellView = value;
            }
	    }

	    public ShellVM()
		{
	    	LoadCommand = new DelegateCommand(ExecuteLoad, () => true);
			SaveCommand = new DelegateCommand(ExecuteSave, () => true);
			Designer = new DesignerVM();
		}

		private static void ExecuteLoad()
		{
			throw new NotImplementedException();
		}


		static void ExecuteSave()
		{
			var dialog = new SaveFileDialog
				{
					Filter = "Advanced Form Designer projects|*.afd|All Files|*.*",
					DefaultExt = "afd"
				};
			if (dialog.ShowDialog() == true)
			{
				const string xml = "";
				using (var fileStream = dialog.OpenFile())
				{
					using (var sw = new StreamWriter(fileStream))
					{
						sw.Write(xml);
						sw.Flush();
						sw.Close();
					}
				}
			}
		}
	}
}
